package com.niknik.woody.rest.rule;

import com.niknik.woody.core.room.GameEx;
import com.niknik.woody.rest.MainRoomRes;
import com.niknik.woody.rest.jersey.RestExHandler;
import com.niknik.woody.utils.wunit.junit.rule.CheckerLogMonitor;
import com.sun.jersey.api.ParamException;

import java.text.MessageFormat;

public class ResLogMonitor
    extends CheckerLogMonitor {

  public void gameExCatch() {
    errCatch(MainRoomRes.class, GameEx.class, null);
  }

  public void resMethodCall(String msg, String... params) {
    methodCall(MainRoomRes.class, msg, params);
  }

  public void resArgErrCatch(String msg, String... params) {
    errCatch(RestExHandler.class, IllegalArgumentException.class, msg, params);
  }

  public void jerseyNumberQueryParamErrCatch(String paramValue) {
    errCatch(RestExHandler.class, ParamException.QueryParamException.class, MessageFormat.format(
        "{0}: For input string: \"{1}\"", NumberFormatException.class.getName(), paramValue));
  }

  public void resThrowableCatch() {
    errCatch(RestExHandler.class, Exception.class, null);
  }

  public void resStateErrCatch(String msg, String... params) {
    errCatch(MainRoomRes.class, IllegalStateException.class, msg, params);
  }
}